package cn.com.klun.util;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class IsWeekendUtil {
    /**
     * 判断一个日期是否是周六、周日
     * @param date
     * @return
     */
    public static boolean isWeekend(String date) throws Exception{
        DateFormat format1 = new SimpleDateFormat("yyyyMMdd");
        Date bdate = null;
        bdate = format1.parse(date);
        Calendar cal = Calendar.getInstance();
        cal.setTime(bdate);
        if(cal.get(Calendar.DAY_OF_WEEK)==Calendar.SATURDAY||cal.get(Calendar.DAY_OF_WEEK)==Calendar.SUNDAY){
            return true;
        }
        else {
            return false;
        }
    }
}
